package me.luochenyxh.module.login.ui.fragment

import android.os.Bundle
import android.widget.CompoundButton
import com.blankj.utilcode.util.ToastUtils
import me.hgj.jetpackmvvm.ext.nav
import me.hgj.jetpackmvvm.ext.navigateAction
import me.luochenyxh.base.base.BaseFragment
import me.luochenyxh.base.ext.hideSoftKeyboard
import me.luochenyxh.module.login.R
import me.luochenyxh.module.login.databinding.LoginFragmentBinding
import me.luochenyxh.module.login.vm.LoginRegisterViewModel

class LoginFragment : BaseFragment<LoginRegisterViewModel, LoginFragmentBinding>() {

    override fun initView(savedInstanceState: Bundle?) {
        mDatabind.click =ProxyClick()
    }

    inner class ProxyClick() {
        /**清空*/
        fun clear() {
            mViewModel.username.postValue("")
        }

        fun login() {
//            when {
//                mViewModel.username.get().isEmpty() -> showMessage("请填写账号")
//                mViewModel.password.get().isEmpty() -> showMessage("请填写密码")
//                else -> requestLoginRegisterViewModel.loginReq(
//                    mViewModel.username.get(),
//                    mViewModel.password.get()
//                )
//            }
            ToastUtils.showShort("登录")
        }


        fun goRegister() {
            hideSoftKeyboard(activity)
//            跳转注册
            nav().navigateAction(R.id.action_loginFragment_to_registerFrgment)
        }

        var onCheckedChangeListener =
            CompoundButton.OnCheckedChangeListener { buttonView, isChecked ->
                mViewModel.isShowPwd.postValue(isChecked)
            }
    }

}